package per.mnxc.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import per.mnxc.common.R;
import per.mnxc.pojo.Lunch;
import per.mnxc.pojo.Tip;
import per.mnxc.service.ILunchService;
import per.mnxc.service.ITipService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mnxc
 * @since 2022-11-26
 */
@Api(tags = "举报信息相关接口")
@RestController
@RequestMapping("/tip")
@CrossOrigin(origins = "*",maxAge = 3600)
public class TipController {
    @Autowired
    ITipService tipService;

    @ApiOperation("分页查询")
    @GetMapping("/page")
    public R<IPage<Tip>> page(int page, int pageSize, String name){
        //构造分页器
        IPage<Tip> pageInfo = new Page<>(page,pageSize);
        //条件
        LambdaQueryWrapper<Tip> lqw = new LambdaQueryWrapper<>();
        lqw.like(name!=null,Tip::getTipCont,name).or()
                .like(name!=null,Tip::getTipType,name);
        //查询数据
        tipService.page(pageInfo,lqw);

        return R.success(pageInfo);
    }

}

